package com.itheima.controller;

import com.itheima.entity.UserModel;
import com.itheima.mapper.UserMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author liudo
 * @version 1.0
 * @project mybatis-plus-quick-start
 * @date 2023/12/22 11:26:15
 */
@RestController
@RequiredArgsConstructor
public class UserController {

    private final UserMapper userMapper;

    /**
     * 分页查询用户信息，且手机号是可选的, 年龄也是可选的
     *
     * @param page
     * @param pageSize
     * @param phone
     * @return
     */
    @GetMapping("/page")
    public List<UserModel> page(Long page, Long pageSize, String phone, Integer age) {

        // Page<User> userPage = new Page<>(page, pageSize);
        // LambdaQueryWrapper<User> queryWrapper = Wrappers.lambdaQuery(User.class);
        // if (phone != null) {
        //     queryWrapper.eq(User::getTel, phone);
        // }
        // if (age != null) {
        //     queryWrapper.eq(User::getAge, age);
        // }
        // // select * from user where tel = null
        // userMapper.selectPage(userPage, phone == null && age == null ? null : queryWrapper);

        return null;
    }
}
